package com.sc.nft.service;


import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.PayOrder;
import com.sc.nft.entity.SecondEquityPropsOrder;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.vo.EquityPoPonsolidatedPaymentDetailsVO;
import com.sc.nft.entity.vo.SecondEquityPropTradingTendPageVO;
import com.sc.nft.entity.vo.secondEquityProp.*;
import com.sc.nft.enums.OrderStatusEnum;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 二级-权益道具订单表服务接口
 *
 * @author Sun
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2024-04-07 14:18:41
 */
public interface SecondEquityPropsOrderService {

    /**
     * 创建订单
     *
     * @param userInfo
     * @param equityPropsId
     * @param productIds
     * @return
     */
    SecondEquityPropCreateOrderVO createOrder(UserInfo userInfo, Long equityPropsId, List<Long> productIds);

    /**
     * 支付成功回调
     *
     * @param payOrder
     * @param orderIds
     */
    void paySuccess(PayOrder payOrder, List<Long> orderIds);

    /**
     * 金额结算
     *
     * @param order
     */
    void extracted(SecondEquityPropsOrder order);

    /**
     * 根据订单来计算实际金额
     *
     * @param user
     * @param equityPropsId
     * @param orderIds
     * @return
     */
    RealAmountVO valuation(UserInfo user, Long equityPropsId, List<Long> orderIds);

    /**
     * 交易趋势详情
     *
     * @param equityPropsId
     * @return
     */
    SecondEquityPropTradingTendDetailsVO tradingTendDetails(Long equityPropsId);

    /**
     * 成交趋势列表
     *
     * @param equityPropsId
     * @param page
     * @return
     */
    Page<SecondEquityPropTradingTendPageVO> flowRecord(Long equityPropsId, Page page);

    /**
     * 订单列表
     *
     * @param page
     * @param user
     * @param status
     * @return
     */
    Page<SecondEquityPropBuyOrderPageVO> orderPage(Page page, UserInfo user, OrderStatusEnum status, Date searchTime);

    SecondEquityPropBuyOrderPageVO buyOrderDetail(UserInfo user, Long id);

    SecondEquityPropBuyOrderPageVO salesOrderDetail(UserInfo user, Long id);

    /**
     * 我出售的订单列表
     *
     * @param page
     * @param user
     * @return
     */
    Page<SecondEquityPropBuyOrderPageVO> salesOrderPage(Page page, UserInfo user, Date searchTime);

    /**
     * 批量取消订单
     *
     * @param equityPropsId
     * @param orderIds
     */
    void batchCancelOrder(Long equityPropsId, List<Long> orderIds, UserInfo user);

    /**
     * 取消订单
     *
     * @param orderId
     */
    void cancelOrder(SecondEquityPropsOrder orderId);

    /**
     * 获取用户即将超时的订单
     *
     * @param offset
     * @return
     */
    List<SecondEquityPropsOrder> getPreTimeOutOrderIds(DateTime offset);

    /**
     * 统计已成交订单
     */
    Integer countOrder(Long userId);

    /**
     * 订单计价
     *
     * @param user
     * @param orderList
     * @return
     */
    RealAmountVO buyValuation(UserInfo user, Long equityPropsId, List<Long> orderList);

    /**
     * 合并支付详情
     *
     * @param user
     * @return
     */
    EquityPoPonsolidatedPaymentDetailsVO consolidatedPaymentDetails(UserInfo user);

    /**
     * 待支付订单详情
     *
     * @param user
     * @param orderId
     * @return
     */
    EquityPropWaitPayOrderDetailsVO waitPayOrderDetails(UserInfo user, Long orderId);

    /**
     * 最新成交价
     *
     * @param equityPropsId
     * @return
     */
    BigDecimal getLastPrice(Long equityPropsId);

    /**
     * 分页查询
     *
     * @param page
     * @param wantBuyOrderId
     * @return
     */
    IPage<SecondEquityPropsOrder> wantBuyOrderPage(Page page, Long wantBuyOrderId);

    /**
     * 分页查询
     *
     * @param page
     * @param wantBuyOrderId
     * @param salesUserId
     * @param startCreateTime
     * @param endCreateTime
     * @param startPayTime
     * @param endPayTime
     * @return
     */
    IPage<SecondEquityPropsOrder> wantBuyOrderPage(Page page, Long wantBuyOrderId, Long salesUserId, Date startCreateTime, Date endCreateTime, Date startPayTime, Date endPayTime);


}
